 <!-- Example table -->
<script type="text/javascript">
	var root_path = '<?php echo _SITE_ADMIN_URL_?>';
	var table = 'product';
	var field = 'product_name';
	
	$(document).ready(function(){
		$('#product_category').change(function(){
			var product_category = $(this).val();
			path = root_path+'ajax/getGeo.php?id='+product_category+'&type=subcategory';
			$.ajax({url: path,	
				success: function(response) {
					$('#product_subcategory').html(response);
				}
			});
			
		});
		$('#product_subsubcategory').bind('change keyup click', function(){
            var product_category = $(this).val();
            path = root_path+'ajax/getGeo.php?id='+product_category+'&type=getattribute';
            $.ajax({url: path,    
                success: function(response) {
                    $('#product_attributes').html(response);
                }
            });
            
        });
        
		$('#product_subcategory').change(function(){
			var product_subcategory = $(this).val();
			path = root_path+'ajax/getGeo.php?id='+product_subcategory+'&type=subcategory';
			$.ajax({url: path,	
				success: function(response) {
					$('#product_subsubcategory').html(response);
				}
			});
			
		});
	});
</script>
<div class="container_12"> 
    <div class="module">
        <h2><span>Add Product</span></h2>
        <div class="module-body">
			<div style="margin-top:13px;">
                <?php
                if(isset($errMsg)){?>
                    <span class="notification"><?php echo $_MESSESGE[$errMsg];?></span>
                <?php }?>
			</div>
                        
            <form id="adminForm" name="admin_frm" action="" method="post" enctype="multipart/form-data">
				<!-- <p>
					<label>Category</label>
					<select class="input-short" id="product_category" name="product_category">
						<option value="">Select Category</option>
						<?php
						foreach($main_categories as $key => $val){
							$selected = ($val['id'] == $parent_id)?'selected':'';?>
							<option value="<?php echo $val['id']; ?>" <?php echo $selected; ?>><?php echo $val['name']; ?></option>
						<?php } ?>
					</select>
				</p>
				<p>
					<label>Sub Category</label>
					<select class="input-short" id="product_subcategory" name="product_subcategory">
						<option value="">Select Sub Category</option>
					</select>
				</p> -->
				<p>
                    <label>Product Name</label>
                    <div id="availability_info"></div>
                    <input type="text" class="input-short check_availability" name="product_name" value="<?php echo $_POST['product_name'];?>" />
                    <!--  <span class="notification-input ni-correct">This is correct, thanks!</span> -->
                </p>

                <p id="subsub_category">
					<label>Sub Sub Category</label>
					<select class="input-short" id="product_subsubcategory" name="product_subsubcategory">
						<option value="">Select Sub Sub Category</option> 
                        <?php 
                            foreach( $sub_sub_categories as $catrow) {
                                echo '<option value="'.$catrow['id'].'">'.$catrow['name'].'</option>';                            
                            }
                        ?>
					</select>
				</p>
				
                <label>Product Attributes</label><p id="product_attributes"></p>
                
				<p>
					<label>Product Description</label>
					<textarea rows="7" cols="90" class="input-short" id="description" name="description"></textarea>
				</p>	
				
				<p>
					<label>Product Tags</label>
					<input type="text" class="input-short" name="tags" value="<?php echo $_POST['name'];?>" />
					<!--  <span class="notification-input ni-correct">This is correct, thanks!</span> -->
				</p> 
				<p>
					<label>Upload Product Image</label>
					<input type="file" name="product_image">
				</p>
				<fieldset>
					<input class="submit-green" type="submit" name="submit" value="Submit" /> 
				   <input class="submit-gray" type="button" value="Cancel" onclick="javascript: window.location='<?php echo _SITE_ADMIN_URL_?>'+'product/product_mng.php';" />
				</fieldset>
			</form>
		</div> <!-- End .module-body -->
	</div>  <!-- End .module -->
</div>
<div style="clear:both;"></div>
<script>
jQuery.validator.addMethod(
		"selectCategoryNone",
		function(value, element) {
			if (element.value == ""){
				return false;
			}
			else return true;
		},
		"Please select a category."
	);
	
	jQuery.validator.addMethod(
		"selectSubCategoryNone",
		function(value, element) {
			if (element.value == ""){
				return false;
			}
			else return true;
		},
		"Please select a sub category."
	);
	
	jQuery.validator.addMethod(
		"selectSubSubCategoryNone",
		function(value, element) {
			if (element.value == ""){
				return false;
			}
			else return true;
		},
		"Please select a sub sub category."
	);
	
	jQuery.validator.addMethod(
		"selectProductAttributesNone",
		function(value, element) {
			if (element.value == ""){
				return false;
			}
			else return true;
		},
		"Please select product attributes."
	);
	
	$().ready(function() {
		$("#adminForm").validate({
			rules: {
				product_category: {
					selectCategoryNone: true
				},
				product_subcategory: {
					selectSubCategoryNone: true
				},
				product_subsubcategory: {
					selectSubSubCategoryNone: true
				},
				product_name: "required",
				description: "required",
				"attributes[]": {
					selectProductAttributesNone: true
				},
				tags: "required",
				product_image: "required"
			 },
			messages: {
				product_name: "Please enter product name",
				description: "Please enter product description",
				tags: "Please enter product tags",
				product_image: "Please enter product image"
			}
		});
	});
</script>
<script type="text/javascript" src="<?php echo _ADMIN_JS_; ?>check_availability.js"></script>